package com.hqyj.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TencentSmsConfig {

    @Autowired
    private SmsConfig smsConfig;

    @Bean
    public SmsClient getSmsCilent(){

        //创建腾讯云短信发送凭证对象，填入secretId和secretKey
        Credential credential = new Credential(smsConfig.getSecretId(),smsConfig.getSecretKey());

        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("sms.tencentcloudapi.com");

        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        //创建短信发送服务平台对象
        SmsClient smsClient = new SmsClient(credential, "ap-guangzhou", clientProfile);
        return smsClient;
    }
}
